Open
restore: support keyspace rename via --keyspace-mapping flag#4811
Conversation
Agent-Logs-Url: https://github.com/scylladb/scylla-manager/sessions/47ee1c2d-5712-4eb2-996c-8851b302cab0 Co-authored-by: tarzanek <504773+tarzanek@users.noreply.github.com>
Agent-Logs-Url: https://github.com/scylladb/scylla-manager/sessions/d07997b2-e3cb-41b2-bc3b-3e3aeffd12fd Co-authored-by: tarzanek <504773+tarzanek@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
tarzanek
April 7, 2026 12:01
View session
tarzanek
marked this pull request as ready for review
April 7, 2026 14:14
tarzanek
requested review from
Michal-Leszczynski,
VAveryanov8 and
karol-kokoszka
as code owners
April 7, 2026 14:14
|
@Michal-Leszczynski can you have a look? ev. we can continue my agent session to add any changes needed from review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for restoring backup data into a differently-named keyspace in the target cluster — a common use case for audits, diffs, and side-by-side comparisons.
Changes
Model / core logic
Target.KeyspaceMappings map[string]string(json:"keyspace_mapping,omitempty") — source→target keyspace pairs; absent from JSON when nil, preserving full backward compatibilityTarget.TargetKeyspace(sourceKs string) string— returns mapped name or identity (nil-safe map lookup)initUnits: storesUnit.Keyspaceas the target keyspace so the entire downstream pipeline (tombstone GC, compaction, load-and-stream, repair, progress tracking) stays consistent without any special-casingcreateRemoteDirWorkloads: appliesTargetKeyspacewhen filtering units and constructingTableNamefor batches, sobatch.Keyspacecarries the target name into all restore operationsvalidateKeyspaceMappings(called frominitTargetonly when mappings are present): ensures every target keyspace exists in the cluster and that no two sources map to the same targetBehavior when flag is omitted
TargetKeyspaceis an identity function when no mapping is set — all code paths are functionally identical to the pre-feature implementation.TestValidatePropertiesexplicitly covers nil, empty, and absent mapping cases.CLI
New
--keyspace-mappingflag onsctool restore, same"src=dst,..."syntax as--dc-mapping. Immutable after task creation (consistent with other core flags). The--keyspacefilter continues to reference source keyspace names.Example
Restores all tables from
ks_prodin the backup intoks_auditin the target cluster. The target keyspace must already exist before the restore starts.Please make sure that: